package com.hison.courseselectionsystem.controller;

import com.hison.courseselectionsystem.service.StudentCourseService;
import com.hison.courseselectionsystem.utils.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @ClassName: StudentCourseController
 * @Descripiton: 学生课程接口   选课   取消选课   查看已选课程
 * @Author: 小郑
 * @Date： 2023/11/17 14:32
 * @Version：1.8
 **/
@Api(value = "学生课程接口",description = "学生可以选课，取消选课，查看已选课程，查看所有课程，")
@RequestMapping("/studentcourse")
@RestController
public class StudentCourseController {

    @Resource
    private StudentCourseService studentCourseService;


    /**
     * 选课   将对应的用户ID  和  课程ID存入学生课程表中
     * @param stuid
     * @param cid
     * @return {@link Result}
     */
    @ApiOperation(value = "选课",notes = "学生选课",produces = "application/json")
    @PostMapping("/choose")
    public Result  choose(@RequestParam("stuId") Integer stuid, @RequestParam("courseId") Integer cid){
        return studentCourseService.choose(stuid,cid);
    }

    /**
     * 取消选课
     * @param stuid
     * @param cid
     * @return {@link Result}
     */
    @ApiOperation(value = "取消已选课程 信息",notes = "学生取消选课", produces = "application/json")
    @DeleteMapping("/delete")
    public Result delete(@RequestParam("stuId") Integer stuid, @RequestParam("courseId") Integer cid){
        return studentCourseService.delete(stuid, cid);
    }


    /**
     * 查看已选课程
     *
     * @param stuid
     * @return {@link Result}
     */
    @ApiOperation(value = "查看该学生 已选的课程信息", notes = "该学生已选的课程信息", produces = "application/json")
    @GetMapping("/list")
    public Result list(@RequestParam("stuid") String stuid){
        return studentCourseService.list(stuid);
    }







}